package cn.com.idmy.auth.context;

import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@AllArgsConstructor
public class RequestForThreadLocal implements Request {
    protected JSONObject request;

    @Override
    public @NotNull Object source() {
        return request;
    }

    @Override
    public @NotNull String body() {
        return "";
    }

    @Nullable
    @Override
    public String getNullableParam(@NotNull String name) {
        return request.getString(name);
    }

    @Override
    public @NotNull List<String> paramNames() {
        return new ArrayList<>(request.keySet());
    }

    @Override
    public @NotNull JSONObject params() {
        return request;
    }

    @Override
    public @NotNull List<String> headerNames() {
        return List.of();
    }

    @Nullable
    @Override
    public String getHeader(@NotNull String name) {
        return request.getString(name);
    }

    @Nullable
    @Override
    public String getCookieValue(@NotNull String name) {
        return request.getString(name);
    }

    @Override
    public @NotNull String uri() {
        return request.getString("url");
    }

    @Override
    public @NotNull String url() {
        return request.getString("url");
    }

    @Override
    public @NotNull String method() {
        return request.getString("method");
    }

    @Nullable
    @Override
    public Object forward(@NotNull String path) {
        return null;
    }

    @Override
    public @NotNull String ipv4() {
        return "";
    }

    @Override
    public @NotNull String ipv6() {
        return "";
    }

    @Override
    public @NotNull Collection<String> headerValues() {
        return List.of();
    }

    @Override
    public @NotNull JSONObject headers() {
        return JSONObject.of();
    }
}
